﻿using System.Drawing;
using ClassMetadataBrowser.Domain;
using System.IO;

namespace ClassMetadataBrowser.ToolControls
{
	public class ProjectFileIconHelper
	{
		public static Bitmap GetIconForFile(ProjectFile file)
		{
			Bitmap bitmap = GetIconForFileInternal(file);
			bitmap.MakeTransparent(bitmap.GetPixel(0, 0));
			return bitmap;
		}

		private static Bitmap GetIconForFileInternal(ProjectFile file)
		{
			switch (Path.GetExtension(file.Name).Trim('.'))
			{
				case "ascx":
					return Icons.ascx;
				case "aspx":
					return Icons.aspx;
				case "asp":
					return Icons.asp;
				case "xml":
					return Icons.xml;
				case "vs":
					return Icons.vs;
				case "xsd":
					return Icons.xsd;
				case "resx":
					return Icons.resx;
				case "css":
					return Icons.css;
				case "bmp":
					return Icons.bmp;
				case "ico":
					return Icons.ico_jpeg_gif;
				case "jpeg":
					return Icons.ico_jpeg_gif;
				case "gif":
					return Icons.ico_jpeg_gif;
				case "cs":
					return Icons.cs;
				default:
					return Icons.generic;
			}
		}
	}
}
